﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using IService.DataDLL;
using IService.Data.IManager;
using IService.Model;

namespace IService.Data.OlbImpl.ManagerImpl
{
	public class NewsDaManagerImpl : INewsDaManager
	{
		public DataTable GetNewsListAll(Type infoType)
		{
			return DataAccess.SelectAll(infoType);
		}

		public DataTable GetNewsListPagin(Type infoType, PagingEntity pe)
		{
			return DataAccess.SelectPaging(infoType, pe);
		}

		public DataTable GetLatestNewsList(Type infoType, int newsnum)
		{
			string WhereClause = "[ShowWebsite]=true";
			string Order = "CreateTime desc";
			return DataAccess.SelectTop(infoType, newsnum, WhereClause, Order);
		}

		public DataTable GetLatestNewsListByType(Type infoType, int newsnum, int type)
		{
			string WhereClause = "[ShowWebsite]=true and [NewsTypeId]=" + type;
			string Order = "CreateTime desc";
			return DataAccess.SelectTop(infoType, newsnum, WhereClause, Order);
		}

		public News GetNewsById(News news)
		{
			news.Select();
			return news;
		}
		/// <summary>
		/// 更新
		/// </summary>
		/// <param name="news"></param>
		/// <returns></returns>
		public bool InsertNews(News news)
		{
			return DataAccess.Insert(news);
		}

		public bool UpdateNews(News news)
		{
			return DataAccess.Update(news);
		}

		public bool DeleteNews(News news)
		{
			return DataAccess.Delete(news);
		}

		public bool DeleteNewsByIds(Type infoType, string Ids)
		{
			string WhereClause = "Id in(" + Ids + ")";
			return DataAccess.Delete(infoType, WhereClause);
		}
	}
}
